package com.usernet.product.dao;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;

import com.usernet.product.comm.BaseDao;
import com.usernet.product.entity.AdminLog;
import com.usernet.product.utils.Page;
import com.usernet.product.utils.PageResult;

/**
 * 管理员操作记录
 * 
 * @author Administrator
 * 
 */
public class AdminLogDao extends BaseDao {

	@SuppressWarnings("unchecked")
	public PageResult<AdminLog> getAllByPage(Page page) {
		String hql = "from AdminLog order by id desc";
		return super.getAllByPageAndHql(page, hql);
	}

	@SuppressWarnings("unchecked")
	public PageResult<AdminLog> getAllByParam(Page page, String loginName,
			Timestamp beginTime, Timestamp endTime) {
		Map<String, Timestamp> map = new HashMap<String, Timestamp>();
		String hql = "from AdminLog where 1=1";
		if (loginName != null && !"".equals(loginName.trim())) {
			hql += " and username like '%" + loginName + "%'";
		}
		if (beginTime != null && endTime != null) {
			hql += " and time>=:beginTime and time<=:endTime";
			map.put("beginTime", beginTime);
			map.put("endTime", endTime);
		}
		hql += " order by id desc";
		return super.getAllByPageAndHql(page, hql, map);
	}
}
